@extends('layouts.master')
@section('head')
	@parent
	<title>FACT - Events</title>

	<script type="text/javascript">
		function printDiv(divId){
			var restorepage = document.body.innerHTML;
			var printcontent = document.getElementById(divId).innerHTML;
			document.body.innerHTML = printcontent;
			window.print();
			document.body.innerHTML = restorepage;
		}
	</script>
@stop

@section('content')		
	<div class="main">
      	<div class="shop_top">      		
			<div id="divPrint" class="container">
				<!-- if admin, show create link -->
				@if(Auth::user()->first_name == 'Admin')
					<div class="container" style="margin-top: -30px;">
						<div class="col-md-1" style="margin-left: -20px;">
							<button class="btn btn-primary"><a href="/events/create" style="color:white;">Create New Event</a></button>
						</div>
						<div class="col-md-1" style="margin-left: 60px;">
							<button class="btn btn-primary" onclick="printDiv('divPrint')"><a style="color:white;">Print Events</a></button>
						</div>
					</div>
				@endif	

	      		<div class="col-md-12 ev-mar">
					<h3 class="m_6 col-md-3" style="margin-left: -32px;">Upcoming Events</h3>
				</div>

				<div>
					@foreach ($c_events as $c_event)
						<div>
							<h4 class="title"><a href="/events/{{$c_event->id}}">{{ $c_event->title }}</a></h4>
							<p class="cart">{{ date("F d, Y l", strtotime($c_event->date)) }} | {{ $c_event->time }}</p>
							<br>
							<br>
						</div>
					@endforeach	
				</div>

		     	<hr />

			   	<div class="col-md-12 ev-mar">
					<h3 class="m_6 col-md-3" style="margin-left: -32px;">Past Events</h3>
				</div>	

				<div>
					@foreach ($p_events as $p_event)
						<div>
							<h4 class="title"><a href="/events/{{$p_event->id}}">{{ $p_event->title }}</a></h4>
							<p class="cart">{{ date("F d, Y l", strtotime($p_event->date)) }} | {{ $p_event->time }}</p>
							<br>
							<br>
						</div>
					@endforeach	
				</div>						
	     	</div>
	   	</div>	   	
  	</div>			
@stop